<div class="form">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'id' => 'account-payable-form',
			'enableAjaxValidation' => false,
		));
?>

	<p class="note">带 <span class="required">*</span> 的是必填的哦！</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model, 'projectId'); ?>
		<?php $this
			->widget('widgets.project.JProjectSelector',
				array(
					'model' => $model,
					'attribute' => 'projectId',
				));
		?>
		<?php echo $form->error($model, 'projectId'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'token'); ?>
		<?php echo $form
			->textField($model, 'token', array(
				'size' => 60,
				'maxlength' => 255
			));
		?>
		<?php echo $form->error($model, 'token'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'payDate'); ?>
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $model,
					'attribute' => 'payDate',
				));
		?>
		<?php echo $form->error($model, 'payDate'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'summary'); ?>
		<?php echo $form
			->textField($model, 'summary', array(
				'size' => 60,
				'maxlength' => 255
			));
		?>
		<?php echo $form->error($model, 'summary'); ?>
	</div>

	
<?php
$summaries = AccountPayable::getPopularSummaries();
foreach ($summaries as $summary) {
?><a class="account-payable-summary-popular" href="#"><?php echo $summary; ?></a>
	<?php
	}
	$summaryFieldId = CHtml::activeId($model, 'summary');
	$script = <<<EOF
	jQuery('.account-payable-summary-popular').click(function(){
	jQuery('#$summaryFieldId').val(jQuery(this).html());
	return false;
});
EOF
	;
	Yii::app()->clientScript->registerScript('account-payable-summary-popular', $script);
	?>

	<div class="row">
		<?php echo $form->labelEx($model, 'merchantId'); ?>
		<?php $this
			->widget('widgets.merchant.JMerchantSelector',
				array(
					'model' => $model,
					'attribute' => 'merchantId',
					'relatedAttribute' => 'merchant'
				));
		?>
		<?php echo $form->error($model, 'merchantId'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'payee'); ?>
		<?php echo $form
			->textField($model, 'payee', array(
				'size' => 60,
				'maxlength' => 255
			));
		?>
		<?php echo $form->error($model, 'payee'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model, 'ticketPayee'); ?>
		<?php echo $form
			->textField($model, 'ticketPayee', array(
				'size' => 60,
				'maxlength' => 255
			));
		?>
		<?php echo $form->error($model, 'ticketPayee'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'type'); ?>
		<?php echo $form
			->dropDownList($model, 'type', AccountPayable::getTypes(),
				array(
					'empty' => ''
				));
		?>
		<?php echo $form->error($model, 'type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'price'); ?>
		<?php echo $form
			->textField($model, 'price', array(
				'size' => 16,
				'maxlength' => 16
			));
		?>
		<?php echo $form->error($model, 'price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model, 'note'); ?>
		<?php echo $form
			->textField($model, 'note', array(
				'size' => 60,
				'maxlength' => 255
			));
		?>
		<?php echo $form->error($model, 'note'); ?>
	</div>

	<?php if (!AccessControl::isAltMode()) { ?>
	<div class="row">
		<?php echo $form->labelEx($model, 'altMode'); ?>
		<?php echo $form->checkBox($model, 'altMode'); ?>
		<?php echo $form->error($model, 'altMode'); ?>
	</div>
	<?php } ?>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '新建' : '保存'); ?>
	</div>
<?php $this->endWidget(); ?>

</div><!-- form -->
